//Copyright (c) 2007 Andrew Badera

//Permission is hereby granted, free of charge, to any person
//obtaining a copy of this software and associated documentation
//files (the "Software"), to deal in the Software without
//restriction, including without limitation the rights to use,
//copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the
//Software is furnished to do so, subject to the following
//conditions:

//The above copyright notice and this permission notice shall be
//included in all copies or substantial portions of the Software.

//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
//EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
//OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
//HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
//WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
//FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
//OTHER DEALINGS IN THE SOFTWARE.


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Forms;

using BadException;
using PownceNET;
using BadUtil;

namespace PownceNET
{
    public partial class frmPownceNET : Form
    {
        private Note note = null;

        public const int REFRESH_MILLI = 15000;

        public frmPownceNET()
        {
            InitializeComponent();
        }

        private void btnUpdateStatus_Click(object sender, EventArgs e)
        {
            txtResponse.Text = "";

            if (txtStatus.Text.Trim().Length > 0)
            {
                try
                {
                    string puser = txtPownceUsername.Text.Trim();
                    if (!string.IsNullOrEmpty(puser))
                    {
                        Note pownceNote = new Note();
                        pownceNote.Recipient = "public";
                        pownceNote.Body = txtStatus.Text;
                        pownceNote.PostNote(puser, txtPowncePwd.Text.Trim());
                    }
                }
                catch (Exception ex)
                {
                    txtResponse.Text = "Pownce Error";

                    BadLogger.WriteToLog("btnUpdateStatus_Click, Pownce", ex, ExceptionEnums.LogEntryType.Error);

                    MessageBox.Show(ex.Message, "Could not post to Pownce", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                }

                txtStatus.Text = string.Empty;
                txtResponse.Text = "OK!";

                //Timeline.GetUserTimeLine();
            }
            else
            {
                txtResponse.Text = "Need msg";
                MessageBox.Show("Please enter a status message.", "Missing status message", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void menuitemAbout_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process proc = new
            System.Diagnostics.Process();
            proc.StartInfo.FileName = "iexplore";
            proc.StartInfo.Arguments = "http://code.google.com/p/powncenet/";
            proc.Start();
        }
    }
}